import { Transform } from 'class-transformer';
import * as dayjs from 'dayjs';
import {
  BaseEntity,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

export class Init extends BaseEntity {
  @CreateDateColumn({
    type: 'timestamp',
    name: 'created_at',
  })
  @Transform(({ value }) => {
    return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
  })
  createdAt: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    name: 'updated_at',
  })
  @Transform(({ value }) => {
    return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
  })
  updatedAt: Date;

  @Column({
    type: 'integer',
    name: 'created_by',
    nullable: true,
  })
  createdBy: number;

  @Column({
    type: 'integer',
    name: 'updated_by',
    nullable: true,
  })
  updatedBy: string;
}
